<?php

namespace App\Http\Requests\Validators\Backend\UserManage;

use App\Http\Requests\Validators\BaseValidator;

class UserValidator extends BaseValidator
{
    public function storeRules()
    {
        return [
            'name' => 'required | string | max:100',
            'gender' => 'required | numeric| in:1,2',
            'phone' => 'required | regex:/^1[345789][0-9]{9}$/',
            'phone' => 'unique:users,phone',
            'card_id' => 'required | string | max:100',
        ];
    }

    public function editRules()
    {
        return [
            'name' => 'string | max:100',
            'gender' => 'numeric| in:1,2',
            'phone' => 'regex:/^1[345789][0-9]{9}$/',
            // 'phone' => 'unique:users,phone',
            'card_id' => 'string | max:100',
        ];
    }

    public function searchRules()
    {
        return [
            'name' => 'string | max:100',
            'nickname' => 'string | max:100',
            'gender' => 'numeric| in:1,2',
            'phone' => 'max:12',
            'card_id' => 'string | max:100',
            'role_ids' => 'string',
            'begin_time' => 'date_format:Y-m-d H:i:s',
            'end_time' => 'date_format:Y-m-d H:i:s',
        ];
    }

    public function favoriteRules()
    {
        return [
            "type" => "required | in:1,2",
            "object_id" => "required | numeric",
        ];
    }

    public function favoriteIndexRules()
    {
        return [
            "type" => "required | in:1,2",
        ];
    }

    public function objectShow()
    {
        return [
            "type" => "required | in:1,2",
        ];
    }
    public function objectIndex()
    {
        return [
            "type" => "required | in:1,2",
        ];
    }

    public function realAuthRules()
    {
        return [
            'name' => 'string | max:100',
            'card_id' => 'string | max:100',
            'resources' => 'array',
        ];
    }
}
